import { createRouter, createWebHashHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";
import UserView from "@/views/home/UserView";
import RoleView from "@/views/home/RoleView";
import MenuView from "@/views/home/MenuView";
import DictionaryView from "@/views/home/DictionaryView";

const routes = [
  {
    path: "/home",
    name: "主页",
    redirect: "/user", // 重定向到第一个子路由
    component: HomeView,
    children: [
      {
        path: "/user",
        name: "用户管理",
        component: UserView,
      },
      {
        path: "/role",
        name: "角色管理",
        component: RoleView,
      },
      {
        path: "/menu",
        name: "菜单管理",
        component: MenuView,
      },
      {
        path: "/dictionary",
        name: "字典管理",
        component: DictionaryView,
      },
    ],
  },
  {
    path: "/",
    name: "首页",
    component: () => import("../views/LoginView.vue"),
  },
  {
    path: "/login",
    name: "登录",
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/LoginView.vue"),
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
